package com.javabasic.algorithm.newcode;

import java.util.HashMap;
import java.util.Scanner;

/**
 * @Author xiongmin
 * @ClassName Allowance
 * @Description TODO
 * @Date 2019/9/1 16:08
 * @Version 1.0
 **/
public class Allowance {
    static Scanner cin = new Scanner(System.in);

    static int n, c;

    public static void main(String[] args) {
        n = cin.nextInt();
        c = cin.nextInt();

        HashMap<Integer, Integer> map = new HashMap<>();
        map.put(0,Integer.MAX_VALUE);
        int coin, num;
        int arr[] = new int[n];
        for (int i = 0; i < n; i++) {
            coin = cin.nextInt();
            num = cin.nextInt();
            map.put(coin,num);
            arr[i] = coin;
        }
        int result = 0;
        for (int i = 0; i < n; i++) {
            if (map.containsKey(arr[i]) && map.containsKey(c-arr[i])) {
                if (arr[i] == c - arr[i]) {
                    result += map.get(arr[i])/2;
                    map.put(arr[i],map.get(arr[i])%2);
                } else {
                    int min = Math.min(map.get(arr[i]),map.get(c-arr[i]));
                    result += min;
                    map.put(arr[i],map.get(arr[i])-min);
                    map.put(c-arr[i],map.get(c-arr[i])-min);
                }
            }
        }
        for (Integer key:
             map.keySet()) {
            if (key > 0 && map.get(key) > 0) {
                if (key >= c) {
                    result += map.get(key);
                } else {
                    int tag = 2;
                    for (int i = 2; ; i++) {
                        tag = i;
                        if (key*tag >= c) {
                            result += map.get(key)/tag;
                            break;
                        }
                    }
                }
            }
        }

        System.out.println(result);
    }
}
